// pages/doctor-case-add-2/doctor-case-add-2.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgUrl: app.globalData.imgUrl,
    choosed: [], // tag 名字数组
    choosedid: [], // 已选标签  id数组
    goodsid: '', // 已选商品id
    caseinfo: [], // 已选商品信息
    hasChoosed: 2, // 是否已选商品 1.已选 2.未选
    doctorInfo: [], // 医生头像姓名
    choosedThreeType: '', // 已选的三级分类名称
    today: '', // 当天日期
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
   
    var choosed = options.choosed.split(",");
    var choosedid = options.choosedid.split(",");
    var date = new Date();
    var today = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate()
    this.setData({
      choosed: choosed,
      choosedid: choosedid,
      choosedThreeType: choosed[2],
      today: today
    });
    wx.setStorageSync('entryType', true); // 从我的案例进入
    this.loadDoctorInfo(); // 头像名字
  },
  // 头像名字
  loadings: function() {
    var that = this;
    app.request({
      url: 'doctor/member/detail',
      data: {

      },
      success: function(res) {
        that.setData({
          core: res.data[0],
          name: res.data[0].name,
          headPic: res.data[0].headPic
        })
      }
    })
  },
    
  // 选择产品
  chosGoods(){
   
    wx.navigateTo({
      url: "../doctor-case-add-3/doctor-case-add-3?goodsId=" + this.data.goodsid + "&choosedid=" + this.data.choosedid[0]
    })
    
  },
  // 下一页
  nextPage: function(e) {
    wx.navigateTo({
      url: '../doctor-case-add-4/doctor-case-add-4?choosedid=' + this.data.choosedid + '&goodsId=' + this.data.goodsid
    })
  },

  // 获取医生个人商品列表
  getGoodsList: function(e) {
    var that = this;
    app.request({
      url: 'doctor/product/getPage',
      data: {
        'pageSize': that.data.pageSize,
        'pageNum': that.data.pageNum,
        'id': wx.getStorageSync('userid'),
      },
      success(res) {
        console.log('医生端医美产品列表:', res)
      }
    })
  },

  loadDoctorInfo: function(e) {
    var that = this;
    app.request({
      url: 'doctor/doctor/doctorDetail',
      data: {
        'doctorId': wx.getStorageSync('userid'),
      },
      success(res) {
        that.setData({
          doctorInfo: res.data[0],
        })
      }
    })
  }
})